package com.linkelee.api.result;

import com.google.common.collect.Maps;
import lombok.Builder;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

import java.io.Serializable;
import java.util.Map;

/**
 * 交互返回信息
 * @author  lsl
 * @time 2018-12-26
 */

@Slf4j
@Data
@Builder
public class JsonResult implements Serializable {

    private static final long serialVersionUID = 458141767787924100L;


    public static final String SUCCESS="0000";
    public static final String TIME_OUT="0001";
    public static final String EXCEPTION="0002";
    public static final String VALID_FAILED="0003";//参数校验错误
    public static final String FAILED="9999";


    private Object data;
    private String code;
    private String msg;

    public JsonResult(){

    }

    public static Map<String,Object> asDataParam(String param,Object object){
        Map dataMap = Maps.newHashMap();
        dataMap.put(param,object);
        return  dataMap;
    }

    public JsonResult(Object data, String code, String msg){
        this.data = data;
        this.code = code;
        this.msg = msg;
    }
}
